import Vue from 'vue';
import Vuex from 'vuex';

// ------------------------------
import createLogger from 'vuex/dist/logger'
import auth from './module/auth'

Vue.use(Vuex);
const debug = process.env.NODE_ENV !== 'production'

export default new Vuex.Store({
    strict: debug,
    plugins: debug ? [createLogger()] : [],
    state: {
      flag: false
    },
    mutations: {
      setFlag (state, flag) {
        state.flag = flag
      }
    },
    actions: {
      addEvent ({commit}) {
        document.addEventListener('keydown', e => {
          if (e.keyCode === 91) {
            commit('setFlag', true)
          }
        })
        document.addEventListener('keyup', e => {
          if (e.keyCode === 91) {
            commit('setFlag', false)
          }
        })
      }
    },
    modules: {
      auth
    },
});
